package com.zkthink.ceres.member.controller;


import com.zkthink.base.R;
import com.zkthink.base.controller.SuperController;
import com.zkthink.ceres.member.dto.MemberAuthenticationPageDTO;
import com.zkthink.ceres.member.dto.MemberAuthenticationSaveDTO;
import com.zkthink.ceres.member.dto.MemberAuthenticationUpdateDTO;
import com.zkthink.ceres.member.entity.MemberAuthentication;
import com.zkthink.ceres.member.service.MemberAuthenticationService;
import com.zkthink.ceres.member.vo.MemberAuthenticationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器 商城会员实名认证
 * </p>
 *
 * @author chenke
 * @date 2020-11-30
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/memberAuthentication")
@Api(value = "MemberAuthentication", tags = "商城会员实名认证")
@AllArgsConstructor
public class MemberAuthenticationController extends SuperController<MemberAuthenticationService, Long, MemberAuthentication, MemberAuthenticationPageDTO, MemberAuthenticationSaveDTO, MemberAuthenticationUpdateDTO> {
    @Autowired
    private MemberAuthenticationService memberAuthenticationService;

    @ApiOperation("新增实名认证")
    @PostMapping("/save")
    public R<Boolean> saveAuthentication(@RequestBody MemberAuthenticationSaveDTO dto) {

        return memberAuthenticationService.saveMemberAuthentication(dto);
    }

    @ApiOperation("查询实名认证")
    @PostMapping("/search")
    public R<MemberAuthenticationVO> searchAuthentication(@RequestBody MemberAuthenticationPageDTO dto) {
        return memberAuthenticationService.searchMemberAuthentication(dto);
    }

    ;

    @ApiOperation("管理员审核实名认证")
    @PostMapping("/update")
    public R<Boolean> updateAuthentication(@RequestBody MemberAuthenticationUpdateDTO dto) {
        return memberAuthenticationService.updateMemberAuthentication(dto);
    }

    ;


    @ApiOperation("查看单一实名认证")
    @GetMapping("/searchMember/{id}")
    public R<MemberAuthentication> searchAuthenticationBydId(@PathVariable("id") Long id) {
        return R.success(memberAuthenticationService.getById(id));
    }

    ;

    @ApiOperation("查看单一实名认证")
    @GetMapping("/searchMemberAuthenticationByMid/{id}")
    public R<MemberAuthentication> searchMemberAuthenticationByMid(@PathVariable("id") Long id) {
        return memberAuthenticationService.searchMemberAuthenticationByMid(id);
    }

    ;
}
